IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'PaymentCreate')
	BEGIN
		DROP  Procedure  PaymentCreate
	END

GO

CREATE Procedure PaymentCreate
(
	@type int,
	@amount money,
	@accountId int,
	@reference nvarchar(250),
	@paymentDate datetime,
	@paymentId int OUTPUT
)
AS

INSERT INTO Payments
	(AccountId, TypeFlag, Amount, Reference, PaymentDate, CreateDate, UpdateDate)
VALUES
	(@accountId, @type, @amount, @reference, @paymentDate, GETDATE(), GETDATE())
	
SET @paymentId = SCOPE_IDENTITY()

GO

